import request from '@/utils/request'

// 获取训练试卷列表
export function getTrainingPapers(params) {
    return request({
        url: '/training-papers',
        method: 'get',
        params
    })
}

// 从错题生成训练试卷
export function generateFromWrongQuestions(data) {
    return request({
        url: '/training-papers/wrong-questions',
        method: 'post',
        data
    })
}

// 随机生成训练试卷
export function generateRandomPaper(subject, questionCount) {
    return request({
        url: '/training-papers/random',
        method: 'post',
        params: { subject, questionCount }
    })
}

// 获取训练试卷题目
export function getTrainingPaperQuestions(id) {
    return request({
        url: `/training-papers/${id}/questions`,
        method: 'get'
    })
}

// 提交训练试卷答案
export function submitTrainingPaper(id, answers) {
    return request({
        url: `/training-papers/${id}/submit`,
        method: 'post',
        data: answers
    })
}

// 获取训练试卷详情
export function getTrainingPaperDetail(id) {
    return request({
        url: `/training-papers/${id}`,
        method: 'get'
    })
}

// 自动保存答案
export function saveTrainingAnswers(id, answers) {
    return request({
        url: `/training-papers/${id}/save`,
        method: 'post',
        data: answers
    })
}

// 获取已保存的答案
export function getSavedAnswers(id) {
    return request({
        url: `/training-papers/${id}/answers`,
        method: 'get'
    })
}

// 获取训练试卷答题结果
export function getTrainingPaperResults(id) {
    return request({
        url: `/training-papers/${id}/results`,
        method: 'get'
    })
} 